// 补零
function addZero(num) {
  return num < 10 ? "0" + num : num;
}
// 格式化时间
function formatDateTime(date) {
  var time = new Date(Date.parse(date));
  time.setTime(time.setHours(time.getHours()));
  var Y = time.getFullYear() + "-";
  var M = addZero(time.getMonth() + 1) + "-";
  var D = addZero(time.getDate()) + " ";
  var h = addZero(time.getHours()) + ":";
  var m = addZero(time.getMinutes()) + ":";
  var s = addZero(time.getSeconds());
  return Y + M + D + h + m + s;
}
export function generateColumns() {
  const COLUMN_WIDTH = window.RPConfig.COLUMN_WIDTH
  return [
    {
      title: "Data ID",
      key: "dataId"
    },
    {
      title: "Group",
      key: "group"
    },
    {
      title: "操作人",
      key: "srcUser"
    },
    {
      title: "最后更新时间",
      key: "lastModifiedTime",
      align: "center",
      minWidth: COLUMN_WIDTH.COLUMN_WIDTH_YYYYMMDDHHMMSS,
      maxWidth: COLUMN_WIDTH.COLUMN_WIDTH_YYYYMMDDHHMMSS + COLUMN_WIDTH.MAX_WIDTH_MORE,
      render: (h, { row }) => {
        return h("span", {}, formatDateTime(row.lastModifiedTime));
      }
    },
    {
      title: this.$t("common.operating"),
      align: "left",
      fixed: "right",
      width: 120,
      render: (h, { row }) => {
        return h("RowTools", {
          props: {
            data: [
              {
                // type: "icon",
                // icon: "md-create",
                text: "详情",
                handle: () => this.goDetail(row)
              },
              {
                // type: "icon",
                // icon: "md-create",
                text: "回滚",
                handle: () => this.goRollBack(row)
              }
            ]
          }
        });
      }
    }
  ];
}
